package com.hdq.controller.admin;

import com.hdq.result.PageResult;
import com.hdq.result.Result;
import com.hdq.service.SkusService;
import dto.RoleAddDTO;
import dto.RoleEditDTO;
import dto.SkusAddDTO;
import dto.SkusEditDTO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/admin/skus")
@Tag(name = "规格管理")
public class SkusController {

    @Autowired
    private SkusService skusService;
    @GetMapping("/{page}")
    @Operation(summary = "分页查询规格")
    public Result<PageResult> selectByPage(@PathVariable Integer page, @RequestParam Integer pageSize) {
        PageResult list= skusService.selectByPage(page,pageSize);
        return Result.success(list);
    }

    @PostMapping
    @Operation(summary = "新增规格")
    public Result insert(@RequestBody SkusAddDTO skusAddDTO) {
        skusService.insert(skusAddDTO);
        return Result.success();
    }

    @DeleteMapping
    @Operation(summary = "删除规格/批量删除")
    public Result delete(@RequestParam List<Long> ids) {
        skusService.delete(ids);
        return Result.success();
    }

    @PutMapping
    @Operation(summary = "更新规格")
    public Result update(@RequestBody SkusEditDTO skusEditDTO) {
        skusService.update(skusEditDTO);
        return Result.success();
    }
    
}
